package com.hibernate.learn4.model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "Colleges")
public class College {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(name = "college_name")
    private String CollegeName;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "student_college",
            joinColumns = @JoinColumn(name = "college_id"),
            inverseJoinColumns = @JoinColumn(name = "student_id"))
    private List<Userr> students = new ArrayList<>();

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCollegeName() {
        return CollegeName;
    }

    public void setCollegeName(String collegeName) {
        CollegeName = collegeName;
    }

    public List<Userr> getStudents() {
        return students;
    }

    public void setStudents(List<Userr> students) {
        this.students = students;
    }

    public void setStudent(Userr student) {
        this.students.add(student);
    }
}
